from PySide6.QtWidgets import QApplication, QCommandLinkButton, QMainWindow, QVBoxLayout, QWidget
from PySide6.QtGui import QPainter, QPalette, QColor
from PySide6.QtCore import Qt


class CustomCommandLinkButton(QCommandLinkButton):
	def __init__(self, parent=None):
		super().__init__(parent)

	def paintEvent(self, event):
		painter = QPainter(self)
		painter.setRenderHint(QPainter.Antialiasing)
		palette = QPalette()
		palette.setColor(QPalette.Base, QColor("#FFD700"))  # 设置背景色为黄色
		self.setPalette(palette)
		super().paintEvent(event)


class MainWindow(QMainWindow):
	def __init__(self):
		super().__init__()
		self.setWindowTitle("Custom Command Link Button Example")

		button = CustomCommandLinkButton()
		button.setText("Click Me")
		button.setDescription("This is a description for the command link.")

		central_widget = QWidget()
		self.setCentralWidget(central_widget)
		layout = QVBoxLayout()
		central_widget.setLayout(layout)
		layout.addWidget(button)


if __name__ == "__main__":
	app = QApplication([])
	window = MainWindow()
	window.show()
	app.exec()